import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter_mvvm/service/publicDio.dart';
import 'package:flutter_mvvm/service/rxNet/rxDartFrame.dart';

class CounterInt with ChangeNotifier {
  int value1 = 0;
  Timer _timer;

  // rxDart.Observable get(String url, {Map<String, dynamic> params}) =>
  //     rxDart.Observable.fromFuture(_get(url, params: params)).asBroadcastStream();

  void increment1() {

    RxdartDio.newPostDio(new NetCallback<String>(
      onCacheFinish: (data) {
        print("缓存回调：" + data);
        value1 = data.length;
        notifyListeners();
      },
      onNetFinish: (data) {
        print("网络回调：" + data);
        value1 = data.length;
        notifyListeners();
      },
      onUnkownFinish: (data) {
        print("未知回调：" + data);
        value1 = -1;
        notifyListeners();
      },
    ));
    // _timer = Timer.periodic(Duration(seconds: 1), (t) {
    //   value1 += 1;
    //   notifyListeners();
    // });

  }

  void cancel() {
    _timer?.cancel();
  }
}